package org.cx.comparator.springtest.dynamic;

import org.cx.comparator.annotations.IDynamicComparatorProvider;
import org.cx.comparator.compare.mode.ObjectCompareContext;
import org.cx.comparator.map.ComparatorFieldMapping;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;


@Component
public class DynamicProvider implements IDynamicComparatorProvider {


    @Override
    public Set<ComparatorFieldMapping> provide(ObjectCompareContext objectCompareContext) {
        Set<ComparatorFieldMapping> comparatorFieldMappings = new HashSet<>();
        comparatorFieldMappings.add(new ComparatorFieldMapping("id","id","id"));
        comparatorFieldMappings.add(new ComparatorFieldMapping("animal","animal","动物"));
        comparatorFieldMappings.add(new ComparatorFieldMapping("person","person","人"));
        return comparatorFieldMappings;
    }

    @Override
    public Map<String, Map<String, String>> nestedFields() {


        HashMap<String, Map<String, String>> hashMap = new HashMap<>();

        HashMap<String, String> innerMap = new HashMap<>();
        HashMap<String, String> innerMap2 = new HashMap<>();
        HashMap<String, String> innerMap3 = new HashMap<>();

        innerMap.put("name", "姓名");
        innerMap.put("address", "地址");
        innerMap.put("food", "食物");

        innerMap2.put("calorie", "卡路里");
        innerMap3.put("name1", "人名");

        hashMap.put("animal", innerMap);
        hashMap.put("food", innerMap2);
        hashMap.put("person", innerMap3);
        return hashMap;
    }
}
